package com.gqzm.iaas.controller;

import com.gqzm.iaas.domain.bo.ListResult;
import com.gqzm.iaas.domain.bo.Result;
import com.gqzm.iaas.domain.bo.VoidResult;
import com.gqzm.iaas.domain.dto.StartAnnotationTaskDTO;
import com.gqzm.iaas.domain.dto.StopTaskDTO;
import com.gqzm.iaas.domain.dto.TaskQueryDTO;
import com.gqzm.iaas.domain.dto.TaskStatusVO;
import com.gqzm.iaas.service.IaasTaskService;
import com.gqzm.iaas.utils.ResultUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName: {@link IaasController}
 * @description: 智能标注服务接口
 * @author: peter qin
 * @date: 2023 11 21
 * @version: 1.0
 **/
@RestController
@RequestMapping
public class IaasController {

    @Resource
    private IaasTaskService iaasTaskService;

    //创建智能标注任务
    @PostMapping("/task/create")
    public Result<String> createSmartAnnotation(
            @RequestBody@Validated StartAnnotationTaskDTO dto) {
        return ResultUtils.result(iaasTaskService.createSmartAnnotation(dto));
    }


    //查询智能标注任务
    @PostMapping("/task/status")
    public ListResult<TaskStatusVO> queryTasks(
            @RequestBody@Validated TaskQueryDTO dto) {
        return ResultUtils.listResult(iaasTaskService.queryTasks(dto));
    }


    //终止智能标注任务
    @DeleteMapping("/task/stop")
    public VoidResult stopTask(
            @RequestBody@Validated StopTaskDTO dto) {
        iaasTaskService.stopTask(dto);
        return ResultUtils.success();
    }

}
